<!--{template mobile/mobile_header}-->
	</head>
	<body>
	<header class="weui-search-bar" id="searchBar">
	    <form class="weui-search-bar__form" action="" onsubmit="return false;">
	        <div class="weui-search-bar__box">
	
	            <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="全部或部分文件名" required="">
	            <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel"><i class="weui-icon-clear"></i></a>
	        </div>
	        <label class="weui-search-bar__label" id="searchText">
	            <span>任务名称或任务板名称</span>
	            <i class="weui-icon-search"></i>
	        </label>
	    </form>
	    <a href="javascript:" class="weui-search-return__cancel-btn" id="searchreturn">取消</a>
	</header>
	<!--搜索框结束-->
	<!--搜索内容开始 -->
	<section class="weui-search-con weui-cells hide" data-height="topheight">
	    <div class="weui-cell weui-cell-search">
	        <div class="weui-cell__hd"><span class="dzz dzz-grade weui-cell__img weui-cell__search"></span></div>
	        <div class="weui-cell__bd">
	            <p><span class="weui-search-word">搜索：</span><i class="weui-search-value"></i></p>
	        </div>
	    </div>
	</section>
	<!--搜索内容结束 -->
	<div id="search_list" class="search-list">
	
    </div>
	
	<script type="text/javascript">
    $(function () {
        //搜索页直接获取焦点
        $('#searchBar').addClass('weui-search-bar_focusing');
        $('#searchBar').find('.weui-search-bar__input').trigger("click").focus();
        //取消搜索返回上一页
        $(document).on('click', '#searchreturn', function () {
            window.history.go(-1);
        })
		//出现搜索按钮
        $(document).off('keyup.search').on('keyup.search', '#searchInput', function (e) {
			console.log(e.keyCode);
			if(e.keyCode==13){
				jQuery('.weui-search-con').trigger('click');
			}
            setTimeout(function () {
                setsearchVal();
            }, 500);
        })
        function setsearchVal() {
            var val = $('#searchInput').val(),
                emptypreg = /^\s*$/;
            val = val.replace(/[\ud800-\udbff][\udc00-\udfff]/gi,'',val);
            $('#searchInput').val(val);
            if (emptypreg.test(val)) {
                jQuery('.weui-search-con').addClass('hide');
                $('#search_list').html('');
            } else {
                jQuery('.weui-search-con').removeClass('hide');
            }
            jQuery('.weui-cell__bd').find('.weui-search-value').text(val);
            height();
        }

        //清空内容
        $(document).off('click.canclesearch').on('click.canclesearch', '#searchCancel', function () {
            $('#searchInput').val('');
            $('.weui-search-con').addClass('hide');
            $('#search_list').html('');
        })
        //搜索结果
        $(document).off('cilck.getdata').on('click.getdata', '.weui-search-con', function () {
            //getSearchData();
			var keyword=$('#searchInput').val();
			var url='{MOD_URL}&op=ajax&do=search&keyword='+encodeURI(keyword)+'&submit=1'
			if(keyword){
				jQuery.get(url,function(html){
					jQuery('#search_list').html(html);
				});
			}else{
				$('#searchInput').focus();
				return
			}
			
			
        })

    })

    //获取id高度
    function height(){
        var h = $(document).outerHeight(true);
        var h1 = $('#searchBar').outerHeight(true);
        var h2 = $('.weui-search-con').outerHeight(true);
        if($('.weui-search-con').hasClass('hide')){
            $('.weui-cell-search-images').css('height',h-h1);
        }else{
            $('.weui-cell-search-images').css('height',h-h1-h2);
        }
        $('.weui-cells__margin_footer').css('margin-bottom',0);
    }

</script>
</body>
</html>
